<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - 注册</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> <link href="${base}/res/plugins/hplus/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${base}/res/plugins/hplus/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${base}/res/plugins/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${base}/res/plugins/hplus/css/animate.css" rel="stylesheet">
    <link href="${base}/res/plugins/hplus/css/style.css?v=4.1.0" rel="stylesheet">
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>

</head>

<body class="gray-bg">

<div class="middle-box text-center loginscreen   animated fadeInDown">
    <div>
        <div>

            <h1 class="logo-name" style="font-size: 110px"></h1>

        </div>
        <h3>欢迎注册</h3>
        <p>创建一个新账户</p>

        <form class="form-horizontal m-t" action="${base}/shop/member/ajaxRegister" method="post" id="regForm">
            <div class="form-group">
                <label class="col-sm-4 control-label">姓名：</label>
                <div class="col-sm-8">
                    <input id="username" name="member.username" minlength="2" type="text" class="form-control" required="" aria-required="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-4 control-label">密码：</label>
                <div class="col-sm-8">
                    <input id="password" name="member.password" type="text" class="form-control" required="" aria-required="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-4 control-label">重复密码：</label>
                <div class="col-sm-8">
                    <input name="rePassword" type="text" class="form-control" required="" aria-required="true">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-4 control-label">E-mail：</label>
                <div class="col-sm-8">
                    <input id="cemail" type="email" class="form-control" name="member.email" required="" aria-required="true">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-4 control-label">验证码：</label>
                <div class="col-sm-8 ">
                    <div class="input-group">
                        <input class="form-control" placeholder="验证码" type="text" id="captcha" name="captchaToken" aria-required="true">
                        <span class="input-group-btn">
                            <img id="captchaImage" src="${base}/captcha?width=100&height=35&fontsize=30" alt="换一张" />
                            <input id="isAgreeAgreement" type="hidden" name="isAgreeAgreement" value="true" class="form-control">
                            <input type="hidden" name="shopId" value="0" class="form-control">
                        </span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-3">
                    <button class="btn btn-primary" type="submit">提交</button>
                </div>
            </div>
            <p class="text-muted text-center"><small>已经有账户了？</small><a href="${base}/admin/login">点此登录</a>
        </form>

    </div>
</div>

<!-- 全局js -->
<script src="${base}/res/plugins/hplus/js/jquery.min.js?v=2.1.4"></script>
<script src="${base}/res/plugins/hplus/js/bootstrap.min.js?v=3.3.6"></script>
<!-- iCheck -->
<script src="${base}/res/plugins/hplus/js/plugins/iCheck/icheck.min.js"></script>

<script src="${base}/res/plugins/hplus/js/plugins/validate/jquery.validate.min.js"></script>
<script src="${base}/res/plugins/hplus/js/plugins/validate/messages_zh.min.js"></script>
<script src="${base}/res/plugins/hplus/js/plugins/form/jquery.form.js"></script>
<script src="${base}/res/plugins/hplus/js/web/form-validate.js"></script>
<script>
    $(document).ready(function () {
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
    });

    $().ready( function() {
        var $captcha = $("#captcha");
        var $captchaImage = $("#captchaImage");

        $captchaImage.click( function() {
            var timestamp = (new Date()).valueOf();
            var imageSrc = $captchaImage.attr("src");
            if(imageSrc.indexOf("?") >= 0) {
                imageSrc = imageSrc.substring(0, imageSrc.indexOf("?"));
            }
            imageSrc = imageSrc + "?timestamp=" + timestamp + "&width=100&height=35&fontsize=30";
            $captchaImage.attr("src", imageSrc);
        });


        // prepare the form when the DOM is ready
        var options = {
            beforeSubmit:  showRequest,  // pre-submit callback
            success:       showResponse  // post-submit callback
        };

        $('#regForm').submit(function() {
            $(this).ajaxSubmit(options);
            return false;
        });

        function showRequest(formData, jqForm, options) {
            return $("#regForm").valid();
        }

        function showResponse(responseText, statusText, xhr, $form)  {
            if(responseText.status == 'error'){
                alert(responseText.message);
            }else{
                alert('注册成功');
                window.location.href = '${base}/admin/login';
            }
        }

    });
</script>

</body>

</html>
